<template>
	<view>
		<image mode="widthFix" src="/static/images/mine/top-img.png" class="top-img"></image>
		<view class="info flex align">
			<image src="/static/images/mine/head.png"></image>
			<navigator url="/pages/login/login" hover-class="none" v-if="info==''">请登录</navigator>
			<view v-else>{{info.realname==null?'微信用户':info.realname}}</view>
		</view>
		<view class="main">
			<view class="title">
				常用功能
			</view>
			<view class="card">
				<view @click="toUrl('/pages/apply/record')" class="item flex align between">
					<view class="name flex align">
						姓名
					</view>
					<view>周周</view>
				</view>
				<!-- <view @click="toUrl('/pages/suggest/record')" class="item flex align between">
					<view class="name flex align">
						<image src="/static/images/mine/icon2.png"></image>
						<view>诉求记录</view>
					</view>
					<uni-icons type="right" size="14"></uni-icons>
				</view>
				<view @click="toUrl('/pages/profile/detail')" class="item flex align between">
					<view class="name flex align">
						<image src="/static/images/mine/icon3.png"></image>
						<view>编辑个人信息</view>
					</view>
					<uni-icons type="right" size="14"></uni-icons>
				</view>
				<view @click="toUrl('/pages/login/loginM')" class="item flex align between">
					<view class="name flex align">
						<image src="/static/images/mine/icon5.png"></image>
						<view>管理员账号</view>
					</view>
				</view> -->
			</view>
		</view>

	</view>
</template>
<script>
	import {
		userDetail,
	} from '@/api/apiData.js';
	export default {
		data() {
			return {
				info: '',
				list: []
			}
		},
		onLoad() {

		},
		onShow() {
			let token = uni.getStorageSync('token')
			let that = this
			uni.request({
				url: 'https://xsdy.ncscloudmedia.com/index.php/api/user/checkToken',
				data: {},
				method: 'POST',
				header: {
					'content-type': 'application/json',
					'token': token
				},
				success: result => {
					if (result.data.code == 1) {
						that.getDetail()
					} else {

					}
				},
				fail: result => {
					uni.hideLoading();
				}
			})
		},

		onReady() {

		},
		onShareAppMessage(res) {

		},
		methods: {
			toUrl(u) {
				if(this.info==''){
					uni.showToast({
						title:'请登录',
						icon:'error'
					})
					
				}else{
					uni.navigateTo({
						url: u
					})
				}
				
			},
			async getDetail() {
				const result = await userDetail()
				if (result.code == 1) {
					this.info = result.data
				} else {
					uni.showToast({
						title: result.msg,
						icon: 'error'
					});
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.top-img {
		width: 100%;
		height: 200rpx;
	}

	.info {
		position: absolute;
		top: 150rpx;
		color: white;
		left: 30rpx;

		image {
			width: 128rpx;
			height: 128rpx;
			margin-right: 24rpx;
		}
	}

	.main {
		margin: 20rpx 24rpx;
	}

	.title {
		color: #C23015;
		border-left: solid;
		padding-left: 13rpx;
	}

	.card {
		background: white;
		border-radius: 8rpx;
		margin-top: 24rpx;
		padding-bottom: 150rpx;

		.item {
			padding: 22rpx 24rpx;
			border-bottom: solid 1rpx #F6F6F6;

			image {
				width: 24rpx;
				height: 24rpx;
				margin-right: 20rpx;
			}
		}
	}
</style>